﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Script.Serialization;
using HFController;

namespace HFWebApp.AjaxSource
{
    /// <summary>
    /// AskSource 的摘要说明
    /// </summary>
    public class AskSource : IHttpHandler
    {
        BagePages bp = new BagePages();
        public void ProcessRequest(HttpContext context)
        {
            List<hf.Model.Ask> askList = null;
            int typeid = int.Parse(bp.GetQuery("type"));
            
            if (typeid == 0)
                askList = AskController.getController().getAskList(8);
            else if(typeid == 1)
                askList = AskController.getController().getAskList(8, 1);
            else
                askList = AskController.getController().getAskList(12 ,"LastLoginTime");

            context.Response.ContentType = "text/plaidn";
            context.Response.Write(this.getJSONResult(askList));
            context.Response.End();
        }

        protected string getJSONResult(List<hf.Model.Ask> result)
        {
            JavaScriptSerializer jsSerializer = new JavaScriptSerializer(new SimpleTypeResolver());
            return jsSerializer.Serialize(result);
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}